package net.ccbluex.liquidbounce.features.module.modules.zamx

import net.ccbluex.liquidbounce.event.*
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.ModuleCategory
import net.ccbluex.liquidbounce.features.module.ModuleInfo
import net.ccbluex.liquidbounce.injection.backend.unwrap
import net.ccbluex.liquidbounce.utils.ClientUtils
import net.ccbluex.liquidbounce.utils.MovementUtils
import net.ccbluex.liquidbounce.value.BoolValue
import net.ccbluex.liquidbounce.value.IntegerValue
import net.ccbluex.liquidbounce.value.ListValue
import net.minecraft.entity.EntityLivingBase
import net.minecraft.network.Packet
import net.minecraft.network.play.INetHandlerPlayClient
import net.minecraft.network.play.server.*
import net.minecraft.network.play.client.*
import net.minecraft.util.EnumFacing
import net.minecraft.util.math.BlockPos

import java.util.*
import java.util.concurrent.LinkedBlockingQueue
import javax.swing.text.Position

@ModuleInfo(name = "EasyGrimFull", description = "bypass newhyt 0915", caname = "直接用的全反",category = ModuleCategory.ZAMX)
class EasyGrimFull: Module() {

    private var S08 = 0
    private var isvel = false
    private val C07NoBreak = BoolValue("C07NoBreak" ,true)


    override fun onEnable() {
        if (mc.thePlayer == null) return

    }
    override fun onDisable(){
        if (mc.thePlayer == null) return
    }
    @EventTarget
    fun onMotion(event: MotionEvent) {
        if (event.eventState == EventState.PRE && isvel) {
            isvel = false
            val blockPos = BlockPos(mc2.player.posX, mc2.player.posY, mc2.player.posZ)
            mc2.connection!!.sendPacket(
                    CPacketPlayerDigging(
                            CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK,
                            blockPos,
                            EnumFacing.NORTH
                    )
            )
        }
    }

    @EventTarget
    fun onPacket(event: PacketEvent){
        if (C07NoBreak.get() && mc.gameSettings.keyBindAttack.isKeyDown)
            return
        val packet = event.packet.unwrap()

        if(S08>0){
            S08--
            return
        }

        if(packet is SPacketPlayerPosLook){
            S08 = 10

        }

        if (packet is SPacketEntityVelocity) {
            event.cancelEvent()

            isvel = true
        }

    }


}